import { request, config } from '../utils'
const { api } = config
const { schoolList, schoolAdd, deleteSchool, 
    updateSchool, departmentList, depAdd, deleteDepartment, 
    updateDepartment, specialtyList, speAdd, deleteSpe, updateSpe} = api;

//查询所有学校
export async function querySchool(params){
    return request({
        url:schoolList,
        method:'POST',
        data:params
    })
}

//创建学校
export async function addSchool(params){
    console.log(params)
    return request({
        url: `${schoolAdd}?school=${params.school}`,
        method: 'POST',
        data:params,
        withoutToken:true
    })
}

//删除学校
export async function schoolDelete(params){
    return request({
        url: `${deleteSchool}?rowguid=${params.rowguid}`,
        method: 'POST',
        data: params,
        withoutToken: true
    })
}

//修改学校名称
export async function schoolUpdate(params){
    return request({
        url: `${updateSchool}?rowguid=${params.rowguid}&school=${params.school}`,
        method: 'POST',
        data:params,
        withoutToken: true
    })
}

//查询所有学校下面的所有院系
export async function queryDepartmentList(params){
    return request({
        url: `${departmentList}?schoolguid=${params}`,
        method:'POST',
        withoutToken:true
    })
}

//创建院系
export async function addDepart(params){
    return request({
        url: `${depAdd}?schoolguid=${params.schoolguid}&department=${params.department}`,
        method: 'POST',
        withoutToken:true
    })
}

//删除院系
export async function deleteDepart(params){
    return request({
        url: `${deleteDepartment}?rowguid=${params}`,
        method: 'POST',
        withoutToken:true
    })
}

//修改院系名称
export async function updateDepart(params){
    return request({
        url: `${updateDepartment}?rowguid=${params.rowguid}&department=${params.department}`,
        method: 'POST',
        withoutToken: true
    })
}

//查询学院下的所有专业
export async function querySpecialty(params){
    return request({
        url: `${specialtyList}?departmentguid=${params}`,
        method: 'POST',
        withoutToken:true
    })
}

//创建专业
export async function addSpecialty(params){
    return request({
        url: `${speAdd}?departmentguid=${params.departmentguid}&specialty=${params.specialty}`,
        method: 'POST',
        withoutToken: true
    })
}

//删除专业
export async function deleteSpecialty(params) {
    return request({
        url: `${deleteSpe}?rowguid=${params}`,
        method: 'POST',
        withoutToken:true
    })
}

//修改专业名称
export async function updateSpecialty(params) {
    return request({
        url: `${updateSpe}?rowguid=${params.rowguid}&specialty=${params.specialty}`,
        method: 'POST',
        withoutToken: true
    })
}